let fs=require('fs')
let path=require('path')
let http=require('http')
let url=require('url')
http.createServer((req,res)=>{
    if(req.url==='/favicon.ico') return;
    let pathname=url.parse(req.url).pathname;

    if(pathname==='/'){
        res.end(fs.readFileSync(path.join(__dirname,'index.html')));
    }
    if(path.extname(pathname)){
        res.end(fs.readFileSync(path.join(__dirname, req.url)));
    }
    if(pathname==='/abc'){
        let str=''
        req.on('data',(chunk)=>{
            str+=chunk
        })
        req.on('end',()=>{
            str=JSON.parse(str)
            console.log(str);
            
        })
        res.end('123')
    }
}).listen(8000)